#include "LocalEvaluateFitnessWorker.h"
#include "../../../Framework/Framework.h"

LocalEvaluateFitnessWorker::LocalEvaluateFitnessWorker()
{
}

void LocalEvaluateFitnessWorker::run()
{
    while (!haltRequested)
    {
        efJob = framework->getEvaluateFitnessJob(this);
        if (efJob == NULL)
        {
            ZThread::Thread::yield();
        }
        else
        {
//            cout << "LEF Worker got a job." << endl;
	        if (environment == NULL)
	            throw No_environment_set_exception();
	                    
	        efJob->setFitness(environment->evaluateFitness(efJob->getSolution()));
            framework->handleWorkerDone(this);
        }
    }
}
